package indi.zhifa.core.enummemo.controller;


import indi.zhifa.core.common.web.entity.ann.ZhiFaRestController;
import indi.zhifa.core.common.web.entity.exception.ServiceException;
import indi.zhifa.core.enummemo.entity.EnumVo;
import indi.zhifa.core.enummemo.entity.IEnumVo;
import indi.zhifa.core.enummemo.service.IEnumMemoService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;

@Slf4j
@Validated
@RequiredArgsConstructor
@RequestMapping(value = "/enums")
@ZhiFaRestController
@Tag(name = "枚举接口")
public class EnumApi {
    
    private final IEnumMemoService mEnumMemoService;

    @Operation(summary = "查找枚举")
    @GetMapping("/{name}")
    public IEnumVo findByName(
            @Parameter(description = "枚举名") @PathVariable(name = "name") String pName) throws ServiceException {
        IEnumVo result = mEnumMemoService.findByName(pName);
        return  result;
    }

    @Operation(summary = "查找枚举列表")
    @GetMapping("/list")
    public EnumVo[] list(){
        EnumVo[] enumDtoList = mEnumMemoService.list();
        return enumDtoList;
    }
}
